#include "stdafx.h"

#include "..\ProgressBar.h"
using namespace TddGui;

#include "DummyDialog.h"

namespace Slow
{
TESTCLASS(ProgressBarTests)
{
	ProgressBar* pb;
	DialogThread* dialogThread;

	void TestInitialize()
	{
		pb = new ProgressBar();
		dialogThread = new DialogThread();

		HWND dlg = dialogThread->StartDialog();
		pb->Init(::GetDlgItem(dlg, IDC_PROGRESSBAR_BILL));
	}
	void TestCleanup()
	{
		delete dialogThread;
		delete pb;
	}

	TESTMETHOD(SetProgressToZeroPercentTest)
	{
		ProgressNotification& pn = *pb;
		pn.Status(0, 100, 0);

		int nLower, nUpper;
		pb->GetRange(nLower, nUpper);
		TddAssert().AreEqual(0, nLower);
		TddAssert().AreEqual(100, nUpper);
		TddAssert().AreEqual(0, pb->GetPos());
	}

	void TestPercentage(int percent)
	{
		ProgressNotification& pn = *pb;
		pn.Status(percent, 100, 0);
		TddAssert().AreEqual(percent, pb->GetPos());
	}
	TESTMETHOD(SetProgressTo50PercentTest)
	{
		TestPercentage(50);
	}
	TESTMETHOD(SetProgressTo100PercentTest)
	{
		TestPercentage(100);
	}

	/* the colors in the progress bar doesn't work if you're using a manifest and running on >= XP.  
	   This test will probably work if you take the manifest out.
	TESTMETHOD(ColorTest)
	{
		ProgressNotification& pn = *pb;
		pn.Status(0, 100, RGB(1, 2, 3));
		TddAssert().AreEqual(RGB(1,2,3), pb->GetBarColor());
	}
	*/
};
}